﻿using System;
using System.ComponentModel;

namespace RG.Common.WPF.Dialogs
{
    [SupportDataBinding]
    public class TextBoxDialogVM : IEditableObject, IEditableDialogDataErrorInfo
    {
        public TextBoxDialogVM()
        {
            Lines = 10;
        }

        public string Text { get; set; }

        public string HintText { get; set; }

        [DependOn("HintText")]
        public bool IsHintVisible
        {
            get { return !string.IsNullOrEmpty(HintText); }
        }

        public bool IsTextNeeded { get; set; }

        public int Lines { get; set; }

        public void BeginEdit()
        {
            Text = "";
        }

        public void EndEdit()
        {
        }

        public void CancelEdit()
        {
            
        }

        public string LastError()
        {
            return String.IsNullOrEmpty(Text) && IsTextNeeded ? "Необходимо ввести хоть что-то..." : "";
        }
    }
}